package com.nowcoder.code.lcof;

import java.util.ArrayList;

public class JZ44 {

    public static void main(String[] args) {
        System.out.println(new JZ44().findNthDigit(2));
    }

    public int findNthDigit(int n) {
        if (n < 10) {
            return n;
        }
        long base = 9;
        long sum = 10;
        long lastsum = 0;
        long lastbase = 1;
        long i = 1;
        while (sum < n) {
            i++;
            lastbase = lastbase + base;
            lastsum = sum;

            base = base * 10;
            sum = sum + base * i;
        }

        long t = n - lastsum;
        long c = t / i;
        long y = t % i;

        long r = lastbase + c ;

        y = i - y;
        Long b = 0L;
        while (y != 0) {
            b = r % 10;
            r = r / 10;
            y--;
        }
        return b.intValue();


    }

}
